<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../css/table.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery-1.8.3.min.js"></script>
<script>
var types=[];
		$(function(){
			loadType();
		});
		
		function loadType(){
			
			$.post('../getByPIDRight.action',{'right.parentid':''},function(data){
				types=data;
					for(var i=0;i<data.length;i++){
						$('#parentid').append('<option value="'+data[i].id+'">'+data[i].name+'</option>');
				}
				init();
			},'json');
			
			$('#save').click(function(){
				update();	
			});
			
		}
		
		function init(){
			$.post('../byIDRight.action',{'right.rid':$('#rid').val()},function(data){
				$('#rname').val(data.name)
				$('#rurl').val(data.url);
				var pid = data.parentid;
				var ops = $('#parentid option');
				for(var i=0;i<ops.length;i++){
					if(ops[i].value==pid){
						document.getElementById('parentid').selectedIndex=i;
						break;
					}
				}
				if(data.noMenu){
					document.getElementById('ztype').selectedIndex=1;
				}else{
					document.getElementById('ztype').selectedIndex=0;	
				}
			},'json');	
		}
		
		function update(){
			$.post('../updateRight.action',{'right.rid':$('#rid').val(),'right.parentid':$('#parentid').val(),'right.rname':$('#rname').val(),'right.rurl':$('#rurl').val(),'right.ztype':$('#ztype').val()},function(data){
				if(data=='1'){
					opener.loadAll();
					window.close();
				}else{
					alert('修改失败！,请检查输入！');
				}
			},'json');	
		}
		
</script>
<title>权限信息修改</title>
</head>

<body>
<div>
<form id="form1">
  <table width="550" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="120" class="table_rightf">编号：</td>
      <td class="tableleftf"><label for="right.rid"></label>
      <input name="right.rid" type="text" disabled="disabled" id="rid" readonly="readonly" value="<%=request.getParameter("id")%>" /></td>
    </tr>
    <tr>
      <td class="table_rightf">父权限：</td>
      <td class="tableleftf"><label for="right.parentid"></label>
        <select name="right.parentid" id="parentid">
          <option value="">无</option>
      </select></td>
    </tr>
    <tr>
      <td class="table_rightf">名称：</td>
      <td class="tableleftf"><label for="right.rname"></label>
      <input type="text" name="right.rname" id="rname" />
      *</td>
    </tr>
    <tr>
      <td class="table_rightf">URL:</td>
      <td class="tableleftf"><label for="right.rurl"></label>
      <input type="text" name="right.rurl" id="rurl" />
      （相对）*</td>
    </tr>
    <tr>
      <td class="table_rightf">菜单可见：</td>
      <td class="tableleftf"><label for="right.ztype"></label>
        <select name="right.ztype" id="ztype">
          <option value="false" selected="selected">可见</option>
          <option value="true">不可见</option>
        </select></td>
    </tr>
    <tr>
      <td class="table_rightf">&nbsp;</td>
      <td><span class="tableleftf">
        <input type="button" name="button" id="save" value="  保 存  " />
      </span></td>
    </tr>
    <tr>
      <td class="table_rightf">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
  </form>
</div>
</body>
</html>
